package com.zzyl.job;

import com.zzyl.mapper.DeviceDataMapper;
import com.zzyl.vo.DeviceDataVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;
import java.util.List;

@Component
public class MyTask {

    @Autowired
    private DeviceDataMapper deviceDataMapper;

    //    @Scheduled(fixedRate = 2000) //固定速率，每隔2秒执行一次方法
    @Scheduled(cron = "0 56 16 * * ?")
    public void task() {
        System.out.println("江篱令：开始清理过期的设备上报数据...");

        // 首先获取过期的设备数据ID
        List<Long> deviceDataIds = deviceDataMapper.selectIOTDataOutTime();

        // 根据设备ID数据来清理数据
        deviceDataMapper.deleteBantchByIds(deviceDataIds);
    }
}
